/** @file    wCore_Notification.cpp
 *  @author  Alessandro Polo
 *  @version $Id: wCore_Notification.cpp 2618 2010-06-04 09:48:15Z alex $
 *  @brief
 * File containing methods for the wosh::gui::wCore_Notification class.
 * The header for this class can be found in wCore_Notification.h, check that file
 * for class description.
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

 #include "wCore_Notification.h"

 #include <core/ObjectAllocator.h>
 #include <framework/gui/GuiUtilities.h>

 #include "ui_wCore_Notification.h"


using namespace std;
namespace wosh {
 namespace gui {

 WOSH_REGISTER(wosh::gui::wCore_Notification, "wosh::gui::IWidgetSerializable", 1.0, _static_wCore_Notification )
 WOSH_GUI_MAP(wosh::gui::wCore_Notification, "wosh::Notification", 0.0, _static_Map_wCore_Notification )

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

wCore_Notification::wCore_Notification( QWidget* parent )
	: QWidget(parent) {

	this->m_ui = new Ui::wCore_Notification();
	this->m_ui->setupUi(this);

	setWindowIcon( GuiUtilities::createIconFor( getSerializableType() ) );
	setWindowTitle( getSerializableType() );

	loadObject(NULL);
 }

wCore_Notification::~wCore_Notification() {
	delete this->m_ui;
 }

void wCore_Notification::changeEvent(QEvent *e) {
	QWidget::changeEvent(e);
	if ( e->type() == QEvent::LanguageChange )
		this->m_ui->retranslateUi(this);
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

WRESULT wCore_Notification::loadObject( const Notification* notif ) {
	if ( notif == NULL ) {
		this->m_ui->cmbPriority->setCurrentIndex(0);
		this->m_ui->txtPreferredCommunicator->setText("");
		this->m_ui->txtSenderUser->setText("");
		this->m_ui->txtSenderID->setText("");
		this->m_ui->txtRecipentUser->setText("");
		this->m_ui->txtRecipentID->setText("");
		this->m_ui->txtRecipentGroup->setText("");
		this->m_ui->chkReadTS->setChecked(false);
		this->m_ui->chkSentTS->setChecked(false);
		this->m_ui->txtReadTS->setText("");
		this->m_ui->txtSentTS->setText("");
	 }
	else {

	 }
	return WRET_OK;
 }

WRESULT wCore_Notification::saveObject( Notification* notif ) const {
	if ( notif == NULL ) return WRET_ERR_PARAM;
/*
		this->m_ui->cmbPriority->setCurrentIndex(0);
		this->m_ui->txtPreferredCommunicator->text().toLatin1().data();
		this->m_ui->txtSenderUser->text().toLatin1().data();
		this->m_ui->txtSenderID->text().toLatin1().data();
		this->m_ui->txtRecipentUser->text().toLatin1().data();
		this->m_ui->txtRecipentID->text().toLatin1().data();
		this->m_ui->txtRecipentGroup->text().toLatin1().data();
		this->m_ui->chkReadTS->setChecked(false);
		this->m_ui->chkSentTS->setChecked(false);
		this->m_ui->txtReadTS->text().toLong();
		this->m_ui->txtSentTS->text().toLong()
*/
	return WRET_OK;
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

QVariant NotificationTypeModel::data( const QModelIndex &index, int role ) const {
	if ( !index.isValid() )	return QVariant();

	if ( role == Qt::DisplayRole || role == Qt::EditRole ) { // cos completer!
		Notification::TYPE dType = Notification::TYPE_UNKNOWN;
		switch(index.row()) {
			case 0: dType = Notification::TYPE_UNKNOWN; break;
			case 1: dType = Notification::TYPE_TEXTUAL; break;
			case 2: dType = Notification::TYPE_AUDIO; break;
			case 3: dType = Notification::TYPE_IMAGE; break;
			case 4: dType = Notification::TYPE_VIDEO; break;
			case 5: dType = Notification::TYPE_DATA; break;
			default: break;
		 }
		return QVariant( Notification::getNotificationTypeAsString(dType) );
	}
	return QVariant();
 }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////


 }; // namespace gui
}; // namespace wosh
